<template>
<div class="serving-merchandise views-container">
    <el-dialog width="50%" @close="resetDialogFormData({title: '',content: ''})" :visible.sync="dialogTableVisible" custom-class="reset-pwd wlm-form-dialog dialog-table">
        <div class="wlm-form-dialog dialog-table" v-if="dialogTableVisible">
            <div class="wlm-form-header wlm-dialog-fixheader">
                <span class="wlm-dialog-inlenr">{{`${!!formFormatData.api['editForm']['params']['id']?'编辑':'添加'}服务`}}</span>
            </div>
            <el-scrollbar wrap-class="scrollbar-wrapper">
                <div class="wlm-form-content">
                    <div class="wlm-dialog-main">
                        <div class="wlm-dialog-content">
                            <el-form ref="userForm" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
                                <el-form-item label="服务名称" prop="username">
                                    <el-input v-model.trim="formFormatData.formData.title">
                                    </el-input>
                                </el-form-item>
                                <el-form-item label="服务内容" prop="username">
                                    <el-input :autosize="{ minRows: 4, maxRows: 4}" type="textarea"  v-model.trim="formFormatData.formData.content">
                                    </el-input>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                </div>
            </el-scrollbar>
        </div>
        <footer class="flex-row flex-align-c flex-justify-c wlm-dialog-fixfooter">
            <el-button size="small" @click="formFormatSubmit" type="primary">保存</el-button>
        </footer>
    </el-dialog>
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <el-button @click="dialogTableVisible = true" size="small" type="primary">添加服务</el-button>
        </div>
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.platformPack.files" size="small" label-width="80px" class="retail-form" label-position="right">
                <el-form-item label="服务名称：" class="search">
                    <el-input v-model="tableFormatData.platformPack.files.title" placeholder="请输入服务名称" style="width:160px;"></el-input>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button v-waves type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <el-table :ref="tableFormatData.platformPack.key" :data="tableFormatData.platformPack.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <!-- <el-table-column type="selection" width="55">
                </el-table-column> -->
                <el-table-column prop="date" label="服务名称" >
                    <template slot-scope="scope">
                        <span>{{scope.row.title}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="服务内容" >
                    <template slot-scope="scope">
                        <span>{{scope.row.content}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="商品数" >
                    <template slot-scope="scope">
                        <span>{{scope.row.goodsnum}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="添加时间" >
                    <template slot-scope="scope">
                        <span>{{ scope.row.createtime | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <el-button class="wlm-text" type="text" @click="formFormatDialogEditEvt({id:scope.row.id,toggle:'dialogTableVisible'})">编辑</el-button>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-e flex-align-c">
                <!-- <el-row class="pagination-btns">
                    <el-checkbox class="check-all"  true-label="1" false-label="0" v-model="tableFormatData.platformPack.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row> -->
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" 
                :current-page.sync="tableFormatData.platformPack.pagination.page" :page-sizes="tableFormatData.platformPack.pagination.pagesizes" 
                :page-size.sync="tableFormatData.platformPack.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" 
                :total="hasTableData?tableFormatData.platformPack.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  serviceGet,
  serviceEdit,
  serviceIndex,
  serlistDelete
} from '@/api/merchandise'
import waves from '@/directive/waves' // Waves directive
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table'), mixins.getters('Form')],
  name: 'PlatformPackage',
  components: {

  },
  directives: {
    waves
  },
  data() {
    return {
      dialogTableVisible: false,
      formFormatData: {
        key: 'userForm',
        model: {
          noCreateEdit: false,
          bindDialog: 'dialogTableVisible'
        },
        api: {
          editForm: {
            api: serviceGet,
            params: {
              id: ''
            }
          },
          submitForm: serviceEdit
        },
        formData: {
          title: '',
          content: ''
        },
        rules: {

        }
      },
      tableFormatData: {
        current: 'platformPack',
        platformPack: {
          key: 'platformPack',
          api: {
            getList: serviceIndex,
            delList: serlistDelete
          },
          tableData: [],
          files: {
            title: '',
            ids: [],
            checkall: '0'
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.serving-merchandise {}
</style>
